const { spawn, exec } = require("child_process");
const path = require("path");

function startMsService(relativePath) {
    const envPath = path.join(process.cwd(), relativePath);
    console.log("envPath", envPath);
    const p = exec("nest start", {
        cwd: envPath
    });
    p.on('error', error => {
        console.log(error);
    });
    p.stdout.setEncoding('utf8');
    p.stderr.on('error', error => {
        console.log(error);
    })
    p.stdout.on('data', data => {
        console.log(data);
    })
}

const servicesPaths = [
    "packages/ms-log",
    "packages/ms-calc",
    "packages/ms-main",
]

function main() {
    servicesPaths.forEach(path => {
        startMsService(path);
    });
}

main();